package git.soulbgm.listener;

import git.soulbgm.utils.Counter;
import git.soulbgm.utils.LogUtil;
import org.springframework.kafka.annotation.KafkaHandler;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * 消费者的侦听器
 *
 * @author SoulBGM
 * @date 2022/01/13
 */
@Component
@KafkaListener(topics = "kafka-test")
public class ConsumerListener {

    private final LogUtil log = new LogUtil(getClass());

    @KafkaHandler
    public void handle(String value) {
        String[] split = value.split("\\$&");
        log.info("线程:{},发送下标:{}", split[0], split[split.length - 1]);
        Counter.add();
    }

}
